<template>
  <div>
    <van-nav-bar
      left-arrow
      left-text="返回"
      title="设置"
      @click-left="$router.back()"
    />
    <van-cell-group class="mt-10">
      <van-cell title="帐号" />
      <van-cell
        title="登陆密码"
        :value="isLogin ? '已设置' : '未设置'"
        is-link
      />
      <van-cell
        title="安全密码"
        :value="isLogin ? '已设置' : '未设置'"
        is-link
      />
      <van-cell title="清理缓存" value="立即消除" is-link />
    </van-cell-group>

    <div class="buttom bg-fff" @click="logout">
      <span class="base f16">退出登录</span>
    </div>
  </div>
</template>

<script>
// import { logout } from "@/api/user";
import { get } from "@/request/index";
export default {
  data() {
    return {
      isLogin: false,
    };
  },
  methods: {
    // 退出登录：清空token和phone
    logout() {
      get("/user/logout")
        .then((res) => {
          console.log(res);
          this.$store.commit("set_isLogin", false);
          this.$store.commit("set_token", "");
          this.$store.commit("set_phone", "");
          this.$router.back();
        })
        .catch((err) => console.log("登出失败", err));
    },
  },
};
</script>

<style scoped>
.buttom {
  position: fixed;
  bottom: 0;
  height: 50px;
  width: 100%;
  text-align: center;
  line-height: 50px;
}
</style>